/*
 * Lab2.cpp
 *
 *  Created on: 29.10.2013
 *      Author: ulgish
 */

#include <lab2/Lab2.h>

Lab2::Lab2(int storeSize, int consumerCount, int supplierCount){
	this->st = new Store(storeSize);
	this->cs = new Consumer(consumerCount);
	this->sr = new Supplier(supplierCount);
}

void Lab2::go()
{
	this->cs->start((void*)this->st);
	this->sr->start((void*)this->st);
	this->cs->wait(NULL);
	this->sr->wait(NULL);
	DT::writer << "Current state of Store:\n" << this->st->toString();
	DT::writer.flush();
}

Lab2::~Lab2() {
	// TODO Auto-generated destructor stub
	delete this->st;
	delete this->cs;
	delete this->sr;
}
